/*    */ package cc.s2m.web.s2mBlog.freemarker;
/*    */ 
/*    */ import cc.s2m.web.s2mBlog.pojo.Articles;
/*    */ import cc.s2m.web.s2mBlog.pojo.Comment;
/*    */ import cc.s2m.web.s2mBlog.service.IArticles;
/*    */ import cc.s2m.web.s2mBlog.service.IComment;
/*    */ import com.google.common.collect.Lists;
/*    */ import com.google.common.collect.Maps;
/*    */ import freemarker.template.SimpleNumber;
/*    */ import freemarker.template.TemplateMethodModelEx;
/*    */ import freemarker.template.TemplateModelException;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ 
/*    */ public class CommentExt
/*    */   implements TemplateMethodModelEx
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IComment commentService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticles articlesService;
/*    */ 
/*    */   public Object exec(List arguments)
/*    */     throws TemplateModelException
/*    */   {
/* 27 */     List tagList = Lists.newArrayList();
/* 28 */     if ((arguments == null) || (arguments.size() < 1)) {
/* 29 */       return tagList;
/*    */     }
/* 31 */     SimpleNumber number = (SimpleNumber)arguments.get(0);
/* 32 */     int aid = number.getAsNumber().intValue();
/* 33 */     SimpleNumber rows_ = (SimpleNumber)arguments.get(1);
/* 34 */     int rows = rows_.getAsNumber().intValue();
/* 35 */     Comment conditon = new Comment();
/* 36 */     if (aid != -1) {
/* 37 */       conditon.setAid(Integer.valueOf(aid));
/*    */     }
/* 39 */     Map map = Maps.newHashMap();
/* 40 */     map.put("orderBy", "id DESC");
/* 41 */     map.put("pageSize", Integer.valueOf(rows));
/* 42 */     List<Comment> list = this.commentService.getList(conditon, map);
/* 43 */     for (Comment comment : list) {
/* 44 */       comment.setArticles((Articles)this.articlesService.selectByPrimaryKey(comment.getAid()));
/*    */     }
/* 46 */     return list;
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.freemarker.CommentExt
 * JD-Core Version:    0.6.1
 */